package com.tbgov;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.nio.file.Paths;

/**
 * @author 1st
 */
public class CodeGenerator {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://47.120.14.211:3306/tb_gov?useUnicode=true&characterEncoding=UTF-8&useSSL=false", "root", "yHP79sWnxu")
                .globalConfig(builder -> builder
                        .author("1st")
                        // .enableSwagger()         // 开启 Swagger 2 注解
                        .enableSpringdoc() // 开启 Swagger 3 注解
                        .outputDir(Paths.get(System.getProperty("user.dir")) + "/src/main/java")
                        .commentDate("yyyy-MM-dd")
                )
                .packageConfig(builder -> builder
                        .parent("com.tbgov")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder -> builder
                        // .addExclude("user") // 排除不需要生成的表
                        .addInclude("family_poverty_option") // 需要生成的表
                        .entityBuilder()
                        .enableFileOverride()                  // 开启文件覆盖（重点）
                        .enableLombok() // 使用 Lombok
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
